/*     */ package eos.moe.dragoncore.mixins;
/*     */ import com.google.common.collect.Lists;
/*     */ import com.google.common.collect.Multimap;
/*     */ import eos.moe.dragoncore.aca;
/*     */ import eos.moe.dragoncore.interfaces.IItemStack;
/*     */ import eos.moe.dragoncore.pga;
/*     */ import java.text.DecimalFormat;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.UUID;
/*     */ import javax.annotation.Nullable;
/*     */ import net.minecraft.block.Block;
/*     */ import net.minecraft.client.util.ITooltipFlag;
/*     */ import net.minecraft.enchantment.Enchantment;
/*     */ import net.minecraft.enchantment.EnchantmentHelper;
/*     */ import net.minecraft.entity.EnumCreatureAttribute;
/*     */ import net.minecraft.entity.SharedMonsterAttributes;
/*     */ import net.minecraft.entity.ai.attributes.AttributeModifier;
/*     */ import net.minecraft.entity.player.EntityPlayer;
/*     */ import net.minecraft.init.Items;
/*     */ import net.minecraft.inventory.EntityEquipmentSlot;
/*     */ import net.minecraft.item.Item;
/*     */ import net.minecraft.item.ItemStack;
/*     */ import net.minecraft.nbt.NBTTagCompound;
/*     */ import net.minecraft.nbt.NBTTagList;
/*     */ import net.minecraft.util.ResourceLocation;
/*     */ import net.minecraft.util.text.TextFormatting;
/*     */ import net.minecraft.util.text.translation.I18n;
/*     */ import net.minecraftforge.event.ForgeEventFactory;
/*     */ import net.minecraftforge.fml.relauncher.Side;
/*     */ import net.minecraftforge.fml.relauncher.SideOnly;
/*     */ import org.spongepowered.asm.mixin.Final;
/*     */ import org.spongepowered.asm.mixin.Mixin;
/*     */ import org.spongepowered.asm.mixin.Shadow;
/*     */ import org.spongepowered.asm.mixin.injection.At;
/*     */ import org.spongepowered.asm.mixin.injection.Inject;
/*     */ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
/*     */ 
/*     */ @Mixin({ItemStack.class})
/*     */ public abstract class MixinItemStack implements IItemStack {
/*  42 */   private static final UUID ATTACK_DAMAGE_MODIFIER = UUID.fromString("CB3F55D3-645C-4F38-A497-9C13A33DB5CF");
/*  43 */   private static final UUID ATTACK_SPEED_MODIFIER = UUID.fromString("FA233E1C-4180-4865-B01B-BCCE9785ACA3");
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Shadow
/*     */   private NBTTagCompound field_77990_d;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Shadow
/*     */   @Final
/*     */   private Item field_151002_e;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Shadow
/*     */   private int field_77991_e;
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Shadow
/*     */   @Final
/*     */   public static DecimalFormat field_111284_a;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Shadow
/*     */   public abstract boolean func_77942_o();
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Shadow
/*     */   public abstract boolean func_82837_s();
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   @Shadow
/*     */   @Nullable
/*     */   public abstract NBTTagCompound func_179543_a(String paramString);
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*  98 */   private Map<String, Object> meta = new HashMap<>(); @Shadow
/*     */   public abstract String func_82833_r(); @Shadow
/*     */   public abstract boolean func_77981_g(); @Shadow
/*     */   public abstract Item func_77973_b();
/*     */   @Shadow
/*     */   public abstract NBTTagList func_77986_q();
/*     */   @Shadow
/*     */   public abstract Multimap<String, AttributeModifier> func_111283_C(EntityEquipmentSlot paramEntityEquipmentSlot);
/*     */   public Object getMeta(String str) {
/* 107 */     return this.meta.get(str);
/*     */   } @Shadow
/*     */   @Nullable
/*     */   public abstract NBTTagCompound func_77978_p();
/*     */   public Object getMeta(String str, Object object) {
/* 112 */     return this.meta.getOrDefault(str, object);
/*     */   } @Shadow
/*     */   public abstract boolean func_77951_h(); @Shadow
/*     */   public abstract int func_77958_k(); @Shadow
/*     */   public abstract int func_77952_i(); public void setMeta(String str, Object object) {
/* 117 */     this.meta.put(str, object);
/*     */   }
/*     */   
/*     */   @SideOnly(Side.CLIENT)
/*     */   @Inject(method = {"getTooltip"}, at = {@At("HEAD")}, cancellable = true)
/*     */   public void getTooltip(EntityPlayer entityPlayer, ITooltipFlag iTooltipFlag, CallbackInfoReturnable callbackInfoReturnable) {
/* 123 */     if (func_82837_s() || hasLore()) {
/*     */       return;
/*     */     }
/* 126 */     aca aca = pga.q.v((ItemStack)this);
/* 127 */     if (aca == null) {
/*     */       return;
/*     */     }
/*     */ 
/*     */     
/* 132 */     List<String> list = Lists.newArrayList();
/*     */     
/* 134 */     if (!aca.z().isEmpty()) {
/* 135 */       str = TextFormatting.ITALIC + aca.z();
/*     */     } else {
/* 137 */       str = func_82833_r();
/* 138 */       if (func_82837_s()) {
/* 139 */         str = TextFormatting.ITALIC + str;
/*     */       }
/*     */     } 
/*     */ 
/*     */     
/* 144 */     String str = str + TextFormatting.RESET;
/* 145 */     if (iTooltipFlag.func_194127_a()) {
/* 146 */       String str1 = "";
/* 147 */       if (!str.isEmpty()) {
/* 148 */         str = str + " (";
/* 149 */         str1 = ")";
/*     */       } 
/*     */       
/* 152 */       int m = Item.func_150891_b(this.field_151002_e);
/* 153 */       if (func_77981_g()) {
/* 154 */         str = str + String.format("#%04d/%d%s", new Object[] { Integer.valueOf(m), Integer.valueOf(this.field_77991_e), str1 });
/*     */       } else {
/* 156 */         str = str + String.format("#%04d%s", new Object[] { Integer.valueOf(m), str1 });
/*     */       } 
/* 158 */     } else if (!func_82837_s() && this.field_151002_e == Items.field_151098_aY) {
/* 159 */       str = str + " #" + this.field_77991_e;
/*     */     } 
/*     */     
/* 162 */     list.add(str);
/* 163 */     int i = 0;
/* 164 */     if (func_77942_o() && this.field_77990_d.func_150297_b("HideFlags", 99)) {
/* 165 */       i = this.field_77990_d.func_74762_e("HideFlags");
/*     */     }
/*     */     
/* 168 */     if ((i & 0x20) == 0) {
/* 169 */       func_77973_b().func_77624_a((ItemStack)this, (entityPlayer == null) ? null : entityPlayer.field_70170_p, list, iTooltipFlag);
/*     */     }
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 175 */     if (func_77942_o()) {
/* 176 */       if ((i & 0x1) == 0) {
/* 177 */         NBTTagList nBTTagList = func_77986_q();
/*     */         
/* 179 */         for (int m = 0; m < nBTTagList.func_74745_c(); m++) {
/* 180 */           NBTTagCompound nBTTagCompound = nBTTagList.func_150305_b(m);
/* 181 */           int n = nBTTagCompound.func_74765_d("id");
/* 182 */           int i1 = nBTTagCompound.func_74765_d("lvl");
/* 183 */           Enchantment enchantment = Enchantment.func_185262_c(n);
/* 184 */           if (enchantment != null) {
/* 185 */             list.add(enchantment.func_77316_c(i1));
/*     */           }
/*     */         } 
/*     */       } 
/*     */       
/* 190 */       if (this.field_77990_d.func_150297_b("display", 10)) {
/* 191 */         NBTTagCompound nBTTagCompound = this.field_77990_d.func_74775_l("display");
/* 192 */         if (nBTTagCompound.func_150297_b("color", 3)) {
/* 193 */           if (iTooltipFlag.func_194127_a()) {
/* 194 */             list.add(I18n.func_74837_a("item.color", new Object[] { String.format("#%06X", new Object[] { Integer.valueOf(nBTTagCompound.func_74762_e("color")) }) }));
/*     */           } else {
/* 196 */             list.add(TextFormatting.ITALIC + I18n.func_74838_a("item.dyed"));
/*     */           } 
/*     */         }
/*     */       } 
/*     */     } 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     
/* 210 */     for (String str1 : aca.v()) {
/* 211 */       list.add(TextFormatting.DARK_PURPLE + "" + TextFormatting.ITALIC + str1);
/*     */     }
/*     */ 
/*     */     
/* 215 */     EntityEquipmentSlot[] arrayOfEntityEquipmentSlot = EntityEquipmentSlot.values();
/* 216 */     int j = arrayOfEntityEquipmentSlot.length;
/*     */     
/* 218 */     for (int k = 0; k < j; k++) {
/* 219 */       EntityEquipmentSlot entityEquipmentSlot = arrayOfEntityEquipmentSlot[k];
/* 220 */       Multimap<String, AttributeModifier> multimap = func_111283_C(entityEquipmentSlot);
/* 221 */       if (!multimap.isEmpty() && (i & 0x2) == 0) {
/* 222 */         list.add("");
/* 223 */         list.add(I18n.func_74838_a("item.modifiers." + entityEquipmentSlot.func_188450_d()));
/*     */         
/* 225 */         for (Map.Entry entry : multimap.entries()) {
/* 226 */           double d2; AttributeModifier attributeModifier = (AttributeModifier)entry.getValue();
/* 227 */           double d1 = attributeModifier.func_111164_d();
/* 228 */           boolean bool = false;
/* 229 */           if (entityPlayer != null) {
/* 230 */             if (attributeModifier.func_111167_a() == ATTACK_DAMAGE_MODIFIER) {
/* 231 */               d1 += entityPlayer.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111125_b();
/* 232 */               d1 += EnchantmentHelper.func_152377_a((ItemStack)this, EnumCreatureAttribute.UNDEFINED);
/* 233 */               bool = true;
/* 234 */             } else if (attributeModifier.func_111167_a() == ATTACK_SPEED_MODIFIER) {
/* 235 */               d1 += entityPlayer.func_110148_a(SharedMonsterAttributes.field_188790_f).func_111125_b();
/* 236 */               bool = true;
/*     */             } 
/*     */           }
/*     */ 
/*     */           
/* 241 */           if (attributeModifier.func_111169_c() != 1 && attributeModifier.func_111169_c() != 2) {
/* 242 */             d2 = d1;
/*     */           } else {
/* 244 */             d2 = d1 * 100.0D;
/*     */           } 
/*     */           
/* 247 */           if (bool) {
/* 248 */             list.add(" " + I18n.func_74837_a("attribute.modifier.equals." + attributeModifier.func_111169_c(), new Object[] { field_111284_a.format(d2), I18n.func_74838_a("attribute.name." + (String)entry.getKey()) })); continue;
/* 249 */           }  if (d1 > 0.0D) {
/* 250 */             list.add(TextFormatting.BLUE + " " + I18n.func_74837_a("attribute.modifier.plus." + attributeModifier.func_111169_c(), new Object[] { field_111284_a.format(d2), I18n.func_74838_a("attribute.name." + (String)entry.getKey()) })); continue;
/* 251 */           }  if (d1 < 0.0D) {
/* 252 */             d2 *= -1.0D;
/* 253 */             list.add(TextFormatting.RED + " " + I18n.func_74837_a("attribute.modifier.take." + attributeModifier.func_111169_c(), new Object[] { field_111284_a.format(d2), I18n.func_74838_a("attribute.name." + (String)entry.getKey()) }));
/*     */           } 
/*     */         } 
/*     */       } 
/*     */     } 
/*     */     
/* 259 */     if (func_77942_o() && func_77978_p().func_74767_n("Unbreakable") && (i & 0x4) == 0) {
/* 260 */       list.add(TextFormatting.BLUE + I18n.func_74838_a("item.unbreakable"));
/*     */     }
/*     */ 
/*     */     
/* 264 */     if (func_77942_o() && this.field_77990_d.func_150297_b("CanDestroy", 9) && (i & 0x8) == 0) {
/* 265 */       NBTTagList nBTTagList = this.field_77990_d.func_150295_c("CanDestroy", 8);
/* 266 */       if (!nBTTagList.func_82582_d()) {
/* 267 */         list.add("");
/* 268 */         list.add(TextFormatting.GRAY + I18n.func_74838_a("item.canBreak"));
/*     */         
/* 270 */         for (j = 0; j < nBTTagList.func_74745_c(); j++) {
/* 271 */           Block block = Block.func_149684_b(nBTTagList.func_150307_f(j));
/* 272 */           if (block != null) {
/* 273 */             list.add(TextFormatting.DARK_GRAY + block.func_149732_F());
/*     */           } else {
/* 275 */             list.add(TextFormatting.DARK_GRAY + "missingno");
/*     */           } 
/*     */         } 
/*     */       } 
/*     */     } 
/*     */     
/* 281 */     if (func_77942_o() && this.field_77990_d.func_150297_b("CanPlaceOn", 9) && (i & 0x10) == 0) {
/* 282 */       NBTTagList nBTTagList = this.field_77990_d.func_150295_c("CanPlaceOn", 8);
/* 283 */       if (!nBTTagList.func_82582_d()) {
/* 284 */         list.add("");
/* 285 */         list.add(TextFormatting.GRAY + I18n.func_74838_a("item.canPlace"));
/*     */         
/* 287 */         for (j = 0; j < nBTTagList.func_74745_c(); j++) {
/* 288 */           Block block = Block.func_149684_b(nBTTagList.func_150307_f(j));
/* 289 */           if (block != null) {
/* 290 */             list.add(TextFormatting.DARK_GRAY + block.func_149732_F());
/*     */           } else {
/* 292 */             list.add(TextFormatting.DARK_GRAY + "missingno");
/*     */           } 
/*     */         } 
/*     */       } 
/*     */     } 
/*     */     
/* 298 */     if (iTooltipFlag.func_194127_a()) {
/* 299 */       if (func_77951_h()) {
/* 300 */         list.add(I18n.func_74837_a("item.durability", new Object[] { Integer.valueOf(func_77958_k() - func_77952_i()), Integer.valueOf(func_77958_k()) }));
/*     */       }
/*     */       
/* 303 */       list.add(TextFormatting.DARK_GRAY + ((ResourceLocation)Item.field_150901_e.func_177774_c(this.field_151002_e)).toString());
/* 304 */       if (func_77942_o()) {
/* 305 */         list.add(TextFormatting.DARK_GRAY + I18n.func_74837_a("item.nbt_tags", new Object[] { Integer.valueOf(func_77978_p().func_150296_c().size()) }));
/*     */       }
/*     */     } 
/*     */     
/* 309 */     ForgeEventFactory.onItemTooltip((ItemStack)this, entityPlayer, list, iTooltipFlag);
/*     */     
/* 311 */     callbackInfoReturnable.setReturnValue(list);
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\mixins\MixinItemStack.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */